#include<bits/stdc++.h>
using namespace std;

int d[100005],V[100005],a[100005],p[100005];
//int L[100005],r[100005];

int main(){
    freopen("detect.in","r",stdin);
    freopen("detect.out","w",stdout);
    int t;
    cin>>t;
    for(int i=1;i<=t;i++){
        int cnt=0,liu=0;
        int n,m,l,v;//che'liang'shu'liang; ce'su'yi'shu'liang; zhu'gan'dao'chang'du; xian'su
        cin>>n>>m>>l>>v;
        for(int j=1;j<=n;j++){
            cin>>d[j]>>V[j]>>a[j];//ju'zui'nan'duan'ju'li; chu'shi'su'du; jia'su'du
        }
        for(int j=1;j<=m;j++){
            cin>>p[j];//ce'su'yi'wei'zhi
        }
        for(int i=1;i<=n;i++){
            for(int j=1;j<=m;j++){
                if(p[j]>=d[i]){
                    double v1=sqrt(V[i]*V[i]+2*a[i]*(p[j]-d[i]));
                    if(v1>v){
                        cnt++;
                        //cout<<i<<' '<<p[j]<<endl;
                        break;
                    }
                }
            }
        }
        for(int k=1;k<=m;k++){
            int tmp=0;
            for(int i=1;i<=n;i++){
                for(int j=1;j<=m;j++){
                    if(k==j) continue;
                    if(p[j]>=d[i]){
                        double v1=sqrt(V[i]*V[i]+2*a[i]*(p[j]-d[i]));
                        if(v1>v){
                            //cout<<i<<' '<<j<<' '<<p[j]<<endl;
                            tmp++;
                            break;
                        }
                    }
                }
            }
            //cout<<"------------"<<endl;
            //cout<<tmp<<endl;
            //cout<<"------------"<<endl;
            if(tmp<cnt){
                liu++;
            }
        }
        cout<<cnt<<' '<<m-liu<<endl;
    }
    return 0;
}
